<?php
$reviewers = ReviewerHelper::getList($type, $id);
$reviewer_back = ReviewerHelper::getBackups(Reviewer::CLS_DEMAND, fetch_a_int('id'));
?>

<{if $type==Reviewer::CLS_DEMAND}>
	<?php
	$demand = DemandHelper::getDetail($id);
	$audit_flow = $demand['audit_flow'];
	$page_title = '需求审批';
	?>
	<?include "FASHION/page_header.phtml"?>
	<?include "proc/frame_view.phtml"?>
<{elseif $type==Reviewer::CLS_INDENT}>
	<?php
	$indent = IndentHelper::getDetail($id);
	$audit_flow = $indent['audit_flow'];
	$page_title = '订单审批';
	?>
	<?include "FASHION/page_header.phtml"?>
	<?include "indent/frame_view.phtml"?>
<{elseif $type==Reviewer::CLS_QC}>
	<?php
	$inbound = InboundHelper::getDetail($id);
	$audit_flow = $inbound['audit_flow'];
	$rever_name = '质检确认';
	$page_title = '入库质检';
	?>
	<?include "FASHION/page_header.phtml"?>
	<?include "inbound/view_pure.phtml"?>
<{elseif $type==Reviewer::CLS_OUTDEMAND}>
	<?php
	$outbound = BoundHelper::getDetail($id);
	$audit_flow = $indent['audit_flow'];
	$page_title = '领料审批';
	?>
	<?include "FASHION/page_header.phtml"?>
	<?include "outbound/view_pure.phtml"?>
<{/if}>

<div id="form_body"></div>
<?include "rever/frame_reviewers.phtml"?>

<{if $type==Reviewer::CLS_QC}>

	<br/>
	<form method="post" id="form1">
	<center>
	<input type="button" value="返 回" onclick="gback();" /> &nbsp; 
	<{foreach item=rv from=$reviewers }>
	  <{if $rv.user_id == $uid}>
		<input type="hidden" name="pass" value="1" />
		<input type="hidden" name="remark" value="" />
		<input type="submit" <{if $rv.pass>0 }> value="已确认" disabled<{else}> value="质检确认"<{/if}> />
		<{break;}>
	  <{/if}>
	<{/foreach}>
	</center>
	</form>

	<script>
	ajax_form({
                before:function(){ return confirm('确认提交质检确认吗？');}, 
		success: function(jsn){location.reload();},
		failure: function(jsn){show_alert(jsn.message);}
	});
	</script>

<{elseif $audit_flow==1 }>
	<div class="center">
		<br/>审核完毕，全部通过
		<input type="button" value="返 回" class="button" onclick="history.back(-1)" />
	</div>
<{elseif $audit_flow==2}>
	<div class="center">
		<br/>审核失败
		<input type="button" value="返 回" class="button" onclick="history.back(-1)" />
	</div>
<{else}>
	<div id="tempframe">
		<br/>
		<form method="post" id="form1">
		<table class="select">
		<tr class="nobg">
			<td class="right" width="120">审 批</td>
			<td>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
				<input type="radio" name="pass" value="1" id="pass_1" /> <label for="pass_1">通过</label>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
				<input type="radio" name="pass" value="0" id="pass_0" /> <label for="pass_0">不通过</label>
			</td>
		</tr>
		<tr class="nobg">
			<td class="right">批 示</td>
			<td><textarea name="remark" rows="4" cols="50"></textarea></td>
		</tr>
		<tr class="nobg">
			<td colspan=2 class="center">
				<input type="button" value="返 回" class="button goback" onclick="history.back(-1)" /> &nbsp;
				<input type="submit" value="保存信息" class="button" />
			</td>
		</tr>
		</table>
		</form>
	</div>

	<script>
	<? /*有审核失败记录或此用户不是正审核人，禁用输入框*/ ?>
	<? if($audit_flow==2 || ReviewerHelper::getCursor($type, $id)!=UserAuthHelper::uid()){ ?>
		$("#tempframe *").attr('disabled', true);
		$("input.goback").attr('disabled', false);
	<? } ?>
	//$("#form_body").append($('#tempframe'));
	ajax_form({
                before:function(){ return checkPassRedio() && confirm('确认提交审批信息吗？');}, 
		success: function(jsn){location.reload();},
		failure: function(jsn){show_alert(jsn.message);}
	});
        
        function checkPassRedio()
        {
           if($('input[name="pass"]:checked').length==0)
           {
               show_alert("请选择审批是否通过");
               $('input[name="pass"]:eq(0)').focus();
               return false;
           }
           return true;
        }
        
	</script>

<{/if}>


<?include "FASHION/page_footer.phtml"?>
